using MicroMsg.Common.Utils;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Devices;
using System;
namespace MicroMsg.Manager
{
	public class MsgNotifyMgr
	{
		private const string TAG = "MsgNotifyMgr";
		private static double LastNotifyTime;
		private static bool IsInChating(string msgTalker)
		{
			if (string.IsNullOrEmpty(msgTalker))
			{
				return false;
			}
			ChatContainerPage cuChatContainerPage = ChatContainerPage.getCuChatContainerPage();
			if (cuChatContainerPage == null)
			{
				return false;
			}
			ChatContainerPage chatContainerPage = PageManager.getInstance().GetTopPage() as ChatContainerPage;
			return chatContainerPage != null && chatContainerPage == cuChatContainerPage && cuChatContainerPage.mChatPageCtrl != null && cuChatContainerPage.mChatPageCtrl.get_Visibility() != 1 && !(cuChatContainerPage.mChatPageCtrl.cuUser != msgTalker);
		}
		public static void DoNotify(string msgtalker)
		{
			if (WebMMMgr.IsWebMMOnline)
			{
				return;
			}
			double nowSeconds = Util.getNowSeconds();
			if (nowSeconds - MsgNotifyMgr.LastNotifyTime < 2.0)
			{
				return;
			}
			MsgNotifyMgr.LastNotifyTime = nowSeconds;
			if (GConfigMgr.settings.bIsSoundOn && !ChatPageCtrl.IsRecordingOrPlayingVoice())
			{
				if (MsgNotifyMgr.IsInChating(msgtalker))
				{
					NewMsgVoiceManager.PlayAlertNudge();
				}
				else
				{
					NewMsgVoiceManager.PlayNewMsgSound();
				}
			}
			if (GConfigMgr.settings.bIsVibrateOn)
			{
				VibrateController @default = VibrateController.get_Default();
				@default.Start(TimeSpan.FromMilliseconds(500.0));
			}
		}
	}
}
